package com.sxapp.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateAndTime {
	public static String getSystemDate() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String format = df.format(new Date());
		return format;
	}
	public static String getSystemTime() {
		SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
		String format = df.format(new Date());
		return format;
	}
	public static String getSystemDateAndTime() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String format = df.format(new Date());
		return format;
	}
	public static String getCurrentTime() {
		return new Date().getTime()+"";
	}
	//两个日期的减法
	public static Long getDifferDay(String date1) throws ParseException {
		java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");    
    	String format = df.format(new Date());
  		java.util.Date beginDate= df.parse(format);    

  		java.util.Date endDate= df.parse(date1);    

  		long day=(endDate.getTime()-beginDate.getTime())/(24*60*60*1000);    

		return day;
	}
}
